package com.mywebsite.Dao;

import com.mywebsite.Domain.User;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class SqlProvider {
    public String updateuserinfo(User record) {
        BEGIN();
        UPDATE("userinfo");

        if (record.getUsername() != null && record.getUsername() != "") {
            SET("username = #{username,jdbcType=VARCHAR}");
        }

        if (record.getPassword() != null && record.getPassword() != "") {
            SET("password = #{password,jdbcType=VARCHAR}");
        }

        if (record.getUseremail()!= null && record.getUseremail()!= "") {
            SET("useremail = #{useremail,jdbcType=VARCHAR}");
        }

        if (record.getUserinfo() != null && record.getUserinfo() != "") {
            SET("userinfo = #{userinfo,jdbcType=VARCHAR}");
        }

        WHERE("id = #{id}");

        return SQL();
    }
}
